package de.boldt.neanda.engine.core;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;

import javax.swing.JPanel;

public class Universum extends JPanel
{
	public Universum()
	{
		this.setSize(Window.nexusX,Window.nexusY);
		this.setLocation(-(this.getWidth() / 2), -(this.getHeight() / 2));
		this.setBackground(Color.black);
		this.setLayout(null);
	}
	
	@Override
	protected void paintComponent(Graphics g)
	{
		super.paintComponent(g);
		g.setColor(Color.RED);
		
		// Zeichne von Oben nach Unten Linien
		for(int i = 0; i < this.getWidth(); i += 64)
		{
			g.drawLine(i,0,i,this.getHeight());
		}
		 
		// Zeichne von Links nach Rechts Linien
		for(int i = 0; i < this.getHeight(); i += 64)
		{
			g.drawLine(0,i,this.getWidth(),i);
		} 
		
		for(Drawable objects:Engine.drawObjects)
		{
			try
			{
				objects.draw(g);
			}
			catch(NullPointerException e)
			{
				System.err.println("Objekt kann nicht gezeichnet werden!");
			}
		}
		
		g.setFont(new Font("Arial",Font.BOLD,20));
		g.drawString("FPS: " + Engine.fps,Window.viewX + 20, Window.viewY + 20);
	}
}
